import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import ShopCart from './views/ShopCart.vue'
import Login from './views/Login.vue'
import Collect from './views/Collect.vue'
import Order from './views/Order.vue'
import Introduce from './views/Introduce.vue'
import Admin from './views/Admin.vue'
import AdminOrder from './views/AdminOrder.vue'
import User from './views/User.vue'
import AllGoods from '@/views/allgoods/allgoods.vue'
import Layout from '@/views/Layout/Layout.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/user',
      name: 'user',
      component: User
    },
    {
      path: '/admin',
      name: 'admin',
      component: Admin
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    },
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '/', // 路由置空的时候会作为一级路由默认渲染的二级路由
          component: Home
        },
        {
          path: '/allgoods', 
          component: AllGoods
        },
        {
          path: '/shopCart',
          name: 'shopCart',
          meta: {
            auth: true
          },
          component: ShopCart
        },
        {
          path: '/collect',
          name: 'collect',
          meta: {
            auth: true
          },
          component: Collect
        },
        {
          path: '/order',
          name: 'order',
          meta: {
            auth: true
          },
          component: Order
        },
        {
          path: '/introduce',
          name: 'introduce',
          meta: {
            auth: true
          },
          component: Introduce
        },
        {
          path: '/adminOrder',
          name: 'adminOrder',
          component: AdminOrder
        },
      ]
    }
  ]
})
